﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Abp.Domain.Entities;
using EasyCaching.Core.Internal;

namespace Hicap.AuthorizationServer.Core.Managers
{
    public interface IManagerBase<TEntity>
        where TEntity : class, IEntity, ISoftDelete
    {
        [EasyCachingEvict(IsBefore = true, IsAll = true)]
        Task<int> BatchDelete(List<int> list);

        [EasyCachingPut(CacheKeyPrefix = SysConsts.SysName)]
        Task<int> BatchInsertOrUpdate(List<TEntity> list);

        [EasyCachingEvict(IsBefore = true)]
        Task<int> Delete(TEntity entity);

        [EasyCachingEvict(IsBefore = true)]
        Task<int> Delete(int id);

        [EasyCachingAble]
        IQueryable<TEntity> GetQuery(Expression<Func<TEntity, bool>> predicate);

        [EasyCachingPut(CacheKeyPrefix = SysConsts.SysName)]
        Task<int> Insert(TEntity entity);

        [EasyCachingPut(CacheKeyPrefix = SysConsts.SysName)]
        Task<int> InsertAndGetId(TEntity entity);

        [EasyCachingPut(CacheKeyPrefix = SysConsts.SysName)]
        Task<int> InsertOrUpdate(TEntity entity);

        [EasyCachingPut(CacheKeyPrefix = SysConsts.SysName)]
        Task<int> InsertOrUpdateAndGetId(TEntity entity);

        [EasyCachingPut(CacheKeyPrefix = SysConsts.SysName)]
        Task<int> Update(TEntity entity);
    }
}